﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.Common;

namespace Sinacor.UI.Bovespa.Ordens.Communication.Translator
{
    public class JustificativaToModel : BaseTranslator<Model.Justificativa, Bovespa.Ordens.Ordem.JustificativaResponse,
                                            List<Model.Justificativa>, List<Bovespa.Ordens.Ordem.JustificativaResponse>>
    {
        public override Sinacor.UI.Bovespa.Ordens.Model.Justificativa Translate(Sinacor.UI.Bovespa.Ordens.Communication.Bovespa.Ordens.Ordem.JustificativaResponse from)
        {
            if(from == null){
                return null;
            }
            
            Model.Justificativa to = new Sinacor.UI.Bovespa.Ordens.Model.Justificativa();
            
            to.CodigoCliente = from.CodigoCliente;
            to.DataAlteracao = from.DataAlteracao;
            to.DataOperacao = from.DataOperacao;
            to.IdentificadorJustificativa = from.IdentificadorJustificativa;
            to.NumeroOrdem = from.NumeroOrdem;
            to.Texto = from.Texto;
            
            return to;
        }
        
        public ModelCollection<Model.Justificativa> Translate(List<Bovespa.Ordens.Ordem.JustificativaResponse> from){
            if(from == null){
                return null;
            }
            
            ModelCollection<Model.Justificativa> objListJustificativa = new ModelCollection<Sinacor.UI.Bovespa.Ordens.Model.Justificativa>();
            
            for(int i=0; i<from.Count; i++){
                objListJustificativa.Add(Translate(from[i]));
            }
            
            return objListJustificativa;
        }
    }
}
